<?php
if (!defined('admin')) {
    exit();
}
if (power('alevel') <= 1) {
    adminmsg('', '无权限', 1);
}
checktoken();
//$filecount = 0;
if (!transit_channel_cache()) {
    adminmsg('', '更新过渡栏目网址失败', 1);
}

if (cache_is_opend()) {
    $site_cache_list = _cache_site_list_getlist();
    if (is_array($site_cache_list)) {
        foreach ($site_cache_list as $key => $v) {
            cache_delete($key);
        }
        cache_delete('sitecachelist');
    }
}


if (deldir(CacheDir)) {
    if (channelrouter() == false) {
        adminmsg('', '写入路由配置失败', 1);
    }
    adminmsg('', '清空成功', 1);
} else {
    adminmsg('', '清空失败', 1);
}


function deldir($dir)
{
    if (CacheDir != "/" && CacheDir != AppDir) {
        rmdir_recusive($dir, 1);
    } else {
        adminmsg('', "要删除的目录并非缓存目录", 1);
        return false;
    }

    return true;
}